import { createRouter, createWebHistory } from 'vue-router'
import Layout from '@/views/Layout/index.vue'
import Login from '@/views/Login/index.vue'
import Home from '@/views/Home/index.vue'
import Question from '@/views/Question/index.vue'
import Category from '@/views/Category/index.vue'
import SubCategory from '@/views/SubCategory/index.vue'
import Detail from '@/views/Detail/index.vue'
import Cart from '@/views/Card/index.vue'
import Checkout from '@/views/Checkout/index.vue'
import Pay from '@/views/Pay/index.vue'
import PayBack from '@/views/Pay/PayBack.vue'
import Member from '@/views/member/index.vue'
import MemberInfo from '@/views/member/UserInfo.vue'
import MemberOrder from '@/views/member/UserOrder.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: Layout,
      children: [
        {path: '/',component: Home},
        {path: '/question',component: Question},
        {path: '/category/:id',component: Category},
        {path: '/subcategory/:id',component: SubCategory},
        {path: '/detailgoods/:id',component: Detail},
        {path: '/cart',component: Cart},
        {path: '/checkout',component: Checkout},
        {path: '/pay',component: Pay},
        {path: '/paycallback',component: PayBack},
        {path: '/member',component: Member,
        children:[
          {path: 'memberInfo',component: MemberInfo},
          {path: 'memberOrder',component: MemberOrder}
        ]}
      ]
    },
    {
      path: '/login',
      component: Login
    }
  ]
  ,
  scrollBehavior () {
    return {
      top:0
    }
  }
})

export default router
